<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('enterprise/index')}">单位列表</a></li>
			<li class="active"><a href="{:url('enterprise/add')}">新增单位</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('enterprise/add')}">
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>单位名称</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" name="name">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required"></span>单位LOGO</label>
				<div class="col-md-6 col-sm-10">
					<input type="hidden" name="logo" id="thumb" value="">
                    <a href="javascript:uploadOneImage('图片上传','#thumb');">
                            <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="thumb-preview" width="135" style="cursor: hand"/>
                    </a>
                    <input type="button" class="btn btn-sm" onclick="$('#thumb-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#thumb').val('');return false;" value="取消图片">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>地区</label>
				<div class="col-md-6 col-sm-10">
					<select class="form-control" name="area_id">
						<option value="">---请选择---</option>
						<foreach name="area_list" item="vo">
							<option value="{$vo.id}">{$vo.title}</option>
						</foreach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>地址</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" name="address">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>行业</label>
				<label class="checkbox-inline">
					<select class="form-control" name="industry_parent_id" id="parent_list">
						<option value="">---请选择---</option>
					</select>
				</label>
				<label class="checkbox-inline">
					<select class="form-control" name="industry_son_id" id="son_list">
						<option value="">---请选择---</option>
					</select>
				</label>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>标签</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" name="tag">
					<p class="help-block">用','分隔</p>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>营业执照</label>
				<div class="col-md-6 col-sm-10">
					<input type="hidden" name="business_license" id="thumb1" value="">
                    <a href="javascript:uploadOneImage('图片上传','#thumb1');">
                            <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="thumb1-preview" width="135" style="cursor: hand"/>
                    </a>
                    <input type="button" class="btn btn-sm" onclick="$('#thumb1-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#thumb1').val('');return false;" value="取消图片">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>简介</label>
				<div class="col-md-6 col-sm-10">
					<textarea class="form-control" name="introduction"></textarea>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>领导人</label>
				<div class="col-md-6 col-sm-10">
					<select class="form-control" name="leader_id">
						<option value="">---请选择---</option>
						<foreach name="user_list" item="vo">
							<option value="{$vo.id}">{$vo.user_nickname}</option>
						</foreach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>管理人</label>
				<div class="col-md-6 col-sm-10">
					<select class="form-control" name="manage_id">
						<option value="">---请选择---</option>
						<foreach name="user_list" item="vo">
							<option value="{$vo.id}">{$vo.user_nickname}</option>
						</foreach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
				</div>
			</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script type="text/javascript">
		function get_industrylist(parent_id,object_id){
			$.ajax({
				url: '/api/user/base/industry',
				data: {parent_id:parent_id},
				type: 'get',
				success:function(res){
					var json = eval(res.data);
					var html = '<option value="">---请选择---</option>';
					for (var key in json) {
	                    html += '<option value="'+json[key]['id']+'">'+json[key]['name']+'</option>';
	                }
	                $(object_id).html(html);
				}
			});
		}
		get_industrylist(0,'#parent_list');

		$('#parent_list').change(function(){
			var parent_id = $(this).val();
			console.log(parent_id)
			get_industrylist(parent_id,'#son_list');
		})
	</script>
</body>
</html>